package shared;

import java.util.Comparator;
import packet.CommandRequest;

/**
 * Provides a means of comparing packets for priority queues
 * @author Joel Garboden
 */
public class CompObj implements Comparator<CommandRequest>
{
  /**
   * Compares two CommandRequest by priority
   * @param l first CommandRequest to compare
   * @param r second CommandRequest to compare
   * @return 1 if l > r, -1 if less, and 0 if equal
   */
  @Override
  public int compare(CommandRequest l, CommandRequest r) 
  {
    if(l.getPriority() > r.getPriority())
    {
      return 1;
    }
    else if(l.getPriority() < r.getPriority() )
    {
      return -1;
    }
    else
    {
      return 0;
    }
  }
}